<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 7.0.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon.ico">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon.ico">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">
  <link rel="stylesheet" href="/lib/pace/pace-theme-minimal.min.css">
  <script src="/lib/pace/pace.min.js"></script>

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"jjbond.cn","root":"/","scheme":"Gemini","version":"7.8.0","exturl":false,"sidebar":{"position":"right","width":300,"display":"post","padding":18,"offset":12,"onmobile":false,"sidebar_rss":{"text":"RSS","icon":"fa fa-rss","color":"burlywood","link":"atom.xml"}},"copycode":{"enable":true,"show_result":true,"style":"mac"},"back2top":{"enable":true,"sidebar":false,"scrollpercent":true},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":true,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.xml"};
  </script>

  <meta name="description" content="任何时间 任何地点超级侦探 认真办案">
<meta property="og:type" content="website">
<meta property="og:title" content="吉吉邦德">
<meta property="og:url" content="https://jjbond.cn/index.html">
<meta property="og:site_name" content="吉吉邦德">
<meta property="og:description" content="任何时间 任何地点超级侦探 认真办案">
<meta property="og:locale" content="zh_CN">
<meta property="article:author" content="右眼">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="https://jjbond.cn/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : true,
    isPost : false,
    lang   : 'zh-CN'
  };
</script>

  <title>吉吉邦德</title>

  <!-- 球形气泡标签云 -->
  <script type="text/javascript" src="/js/bubble.js"></script>

  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

<link rel="alternate" href="/atom.xml" title="吉吉邦德" type="application/atom+xml">
</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>
      <a target="_blank" rel="noopener" href="https://github.com/Neopo1itan/" class="github-corner" aria-label="View source on GitHub"><svg width="80" height="80" viewBox="0 0 250 250" style="fill:#1f3e5c; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a ><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>
    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">吉吉邦德</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-regular fa-desktop fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-regular fa-tags fa-fw"></i>标签<span class="badge">7</span></a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-regular fa-shapes fa-fw"></i>分类<span class="badge">6</span></a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-regular fa-inbox fa-fw"></i>归档<span class="badge">18</span></a>

  </li>
        <li class="menu-item menu-item-rss">

    <a href="/atom.xml" rel="section"><i class="fa fa-rss fa-fw"></i>RSS</a>

  </li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup">
        <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div id="search-result">
  <div id="no-result">
    <i class="fa fa-spinner fa-pulse fa-5x fa-fw"></i>
  </div>
</div>

    </div>
  </div>

</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content index posts-expand">
            
      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://jjbond.cn/posts/2492.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.png">
      <meta itemprop="name" content="右眼">
      <meta itemprop="description" content="任何时间 任何地点<br>超级侦探 认真办案">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="吉吉邦德">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/posts/2492.html" class="post-title-link" itemprop="url">youyan</a>
        </h2>

        <div class="post-meta">
          
            <i class="fa fa-anchor" style="color:#DC143C"></i>
            <font color=DC143C>置顶</font>
            <span class="post-meta-divider">|</span>
          
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2023-07-06 15:48:11" itemprop="dateCreated datePublished" datetime="2023-07-06T15:48:11+08:00">2023-07-06</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2023-11-25 11:49:46" itemprop="dateModified" datetime="2023-11-25T11:49:46+08:00">2023-11-25</time>
              </span>

          <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="far fa-file-word"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>9</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="far fa-clock"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>1 分钟</span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>图床测试<br>中等大小:<a target="_blank" rel="noopener" href="https://img.tg/image/OrPPjY"><img data-src="" data-original="https://ooo.0x0.ooo/2023/11/25/OrPPjY.jpg" alt="OrPPjY.jpg"></a></p>

      
    </div>

    
    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://jjbond.cn/posts/2317.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.png">
      <meta itemprop="name" content="右眼">
      <meta itemprop="description" content="任何时间 任何地点<br>超级侦探 认真办案">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="吉吉邦德">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/posts/2317.html" class="post-title-link" itemprop="url">JS 性能优化</a>
        </h2>

        <div class="post-meta">
          
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2024-04-15 15:32:12" itemprop="dateCreated datePublished" datetime="2024-04-15T15:32:12+08:00">2024-04-15</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2024-04-16 16:33:57" itemprop="dateModified" datetime="2024-04-16T16:33:57+08:00">2024-04-16</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/JS/" itemprop="url" rel="index"><span itemprop="name">JS</span></a>
                </span>
            </span>

          <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="far fa-file-word"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>1.3k</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="far fa-clock"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>1 分钟</span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h2 id="性能优化进阶"><a href="#性能优化进阶" class="headerlink" title="性能优化进阶"></a>性能优化进阶</h2><h3 id="Navigation-Timing-API"><a href="#Navigation-Timing-API" class="headerlink" title="Navigation Timing API"></a>Navigation Timing API</h3><p><strong>面试</strong>:在代码执行之前，浏览器加载页面发生了什么？<br>&#x3D;&gt; 浏览器原理<br>&#x3D;&gt; 广度：DOM 渲染、存储…</p>
<p><strong>打印当前页面耗时:</strong></p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// index.html</span></span><br><span class="line">&lt;script&gt;</span><br><span class="line">  <span class="attr">javascript</span>:(<span class="function">()=&gt;</span>&#123;</span><br><span class="line">    <span class="keyword">const</span> perfData = <span class="variable language_">window</span>.<span class="property">perfomance</span>.<span class="property">timing</span></span><br><span class="line">    cosnt pageLoadTime = perData.<span class="property">loadEventEnd</span> - perData.<span class="property">navigationStart</span> <span class="comment">// 时间戳之差</span></span><br><span class="line"></span><br><span class="line">    <span class="variable language_">console</span>.<span class="title function_">log</span>(<span class="string">&#x27;当前页面加载耗时:&#x27;</span>,pageLoadTime,<span class="string">&#x27;ms&#x27;</span>)</span><br><span class="line">  &#125;)</span><br><span class="line">&lt;/script&gt;</span><br></pre></td></tr></table></figure>
          <!--noindex-->
            <div class="post-button">
              <a class="btn" href="/posts/2317.html#more" rel="contents">
                阅读全文 &raquo;
              </a>
            </div>
          <!--/noindex-->
        
      
    </div>

    
    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://jjbond.cn/posts/62985.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.png">
      <meta itemprop="name" content="右眼">
      <meta itemprop="description" content="任何时间 任何地点<br>超级侦探 认真办案">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="吉吉邦德">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/posts/62985.html" class="post-title-link" itemprop="url">函数式编程</a>
        </h2>

        <div class="post-meta">
          
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2024-04-11 14:10:04" itemprop="dateCreated datePublished" datetime="2024-04-11T14:10:04+08:00">2024-04-11</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2024-04-15 15:42:55" itemprop="dateModified" datetime="2024-04-15T15:42:55+08:00">2024-04-15</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/JS/" itemprop="url" rel="index"><span itemprop="name">JS</span></a>
                </span>
            </span>

          <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="far fa-file-word"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>1.5k</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="far fa-clock"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>1 分钟</span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h1 id="函数式编程"><a href="#函数式编程" class="headerlink" title="函数式编程"></a>函数式编程</h1><ul>
<li><a href="#%E5%87%BD%E6%95%B0%E5%BC%8F%E7%BC%96%E7%A8%8B">函数式编程</a><ul>
<li><a href="#%E8%B5%B7%E6%BA%90">起源</a></li>
<li><a href="#%E5%8E%9F%E7%90%86%E7%89%B9%E7%82%B9">原理特点</a><ul>
<li><a href="#%E4%BB%80%E4%B9%88%E6%98%AF%E5%87%BD%E6%95%B0%E5%BC%8F%E5%8E%9F%E7%90%86">什么是函数式原理</a></li>
<li><a href="#%E7%90%86%E8%AE%BA%E6%80%9D%E6%83%B3">理论思想</a></li>
</ul>
</li>
<li><a href="#%E5%AE%9E%E9%99%85%E5%BC%80%E5%8F%91">实际开发</a><ul>
<li><a href="#1%E7%BA%AF%E5%87%BD%E6%95%B0%E6%94%B9%E9%80%A0">1.纯函数改造</a></li>
<li><a href="#2%E6%B5%81%E6%B0%B4%E7%BA%BF%E7%BB%84%E8%A3%85-%E5%8A%A0%E5%B7%A5%E7%BB%84%E8%A3%85">2.流水线组装-加工&amp;组装</a><ul>
<li><a href="#%E9%9D%A2%E8%AF%95%E9%A2%98">面试题</a></li>
</ul>
</li>
</ul>
</li>
<li><a href="#%E5%B8%B8%E8%A7%81%E7%9A%84%E4%B8%89%E6%96%B9%E5%BA%93">常见的三方库</a></li>
</ul>
</li>
</ul>
<h2 id="起源"><a href="#起源" class="headerlink" title="起源"></a>起源</h2><p>历程：<br>命令式(脚本) &#x3D;&gt; 面向对象式<br>命令式(脚本) &#x3D;&gt; 函数式</p>
<p>解决代码复用的问题</p>
<h2 id="原理特点"><a href="#原理特点" class="headerlink" title="原理特点"></a>原理特点</h2><h3 id="什么是函数式原理"><a href="#什么是函数式原理" class="headerlink" title="什么是函数式原理"></a>什么是函数式原理</h3><ul>
<li><p>加法结合律 | 因式分解 | 完全平方工时</p>
</li>
<li><p>水源 &#x3D;&gt; 组合（水管 + 走线） &#x3D;&gt; 花洒</p>
</li>
</ul>
<h3 id="理论思想"><a href="#理论思想" class="headerlink" title="理论思想"></a>理论思想</h3><ol>
<li>一等公民——函数 &#x3D;&gt; 1.逻辑功能最终实现的落脚点 2.实现函数+拼接流程</li>
<li>声明式编程</li>
<li>惰性执行-衔接性，性能节约</li>
</ol>
<h2 id="实际开发"><a href="#实际开发" class="headerlink" title="实际开发"></a>实际开发</h2><h3 id="1-纯函数改造"><a href="#1-纯函数改造" class="headerlink" title="1.纯函数改造"></a>1.纯函数改造</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> _class = &#123;</span><br><span class="line">	<span class="attr">name</span>: <span class="string">&#x27;objective&#x27;</span>,</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">// 函数内部引入了外部变量</span></span><br><span class="line"><span class="keyword">const</span> <span class="title function_">score</span> = (<span class="params">str</span>) =&gt; _class.<span class="property">name</span> + <span class="string">&#x27;:&#x27;</span> + str</span><br><span class="line"><span class="comment">// 直接修改了输入参数</span></span><br><span class="line"><span class="keyword">const</span> <span class="title function_">changeClass</span> = (<span class="params">obj, name</span>) =&gt; (obj.<span class="property">name</span> = name)</span><br><span class="line"></span><br><span class="line"><span class="comment">/***** ↓ 修改后 ↓ *****/</span></span><br><span class="line"><span class="keyword">const</span> _class = &#123;</span><br><span class="line">	<span class="attr">name</span>: <span class="string">&#x27;objective&#x27;</span>,</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="keyword">const</span> <span class="title function_">score</span> = (<span class="params">obj, str</span>) =&gt; obj.<span class="property">name</span> + <span class="string">&#x27;:&#x27;</span> + str</span><br><span class="line"><span class="keyword">const</span> <span class="title function_">changeClass</span> = (<span class="params">obj, name</span>) =&gt; (&#123; ...obj, name &#125;)</span><br><span class="line"></span><br><span class="line"><span class="title function_">changeClass</span>(_class, <span class="string">&#x27;functional&#x27;</span>)</span><br><span class="line"><span class="title function_">score</span>(_class, <span class="string">&#x27;good&#x27;</span>)</span><br></pre></td></tr></table></figure>

<h3 id="2-流水线组装-加工-组装"><a href="#2-流水线组装-加工-组装" class="headerlink" title="2.流水线组装-加工&amp;组装"></a>2.流水线组装-加工&amp;组装</h3><ol>
<li>加工 - 科里化</li>
</ol>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// f(x,y,z) =&gt; f(x)(y)(z)</span></span><br><span class="line"><span class="keyword">const</span> <span class="title function_">add</span> = x =&gt; <span class="function"><span class="params">y</span> =&gt;</span> <span class="function"><span class="params">z</span>=&gt;</span> <span class="keyword">return</span> x+y+z;</span><br><span class="line"><span class="title function_">add</span>(<span class="number">1</span>)(<span class="number">2</span>)(<span class="number">3</span>) <span class="comment">// 6</span></span><br><span class="line"><span class="comment">// 要实现 体系=加工+组装，单个加工输入输出应该单值化 =&gt; 单元函数</span></span><br><span class="line"><span class="keyword">const</span> fetch = <span class="title function_">ajax</span>(method,url,params);</span><br><span class="line"><span class="keyword">const</span> fetch = ajax.<span class="title function_">get</span>(method);</span><br><span class="line"><span class="keyword">const</span> request = <span class="title function_">fetch</span>(url);</span><br><span class="line">组合(fetch,request);</span><br></pre></td></tr></table></figure>

<h4 id="面试题"><a href="#面试题" class="headerlink" title="面试题"></a>面试题</h4><p>手写构造可拆分传参的累加函数<br>add(1)(2)(3)(4)</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 构造科里化结构</span></span><br><span class="line"><span class="comment">// 输入 处理外层arguments =&gt; 类数组处理</span></span><br><span class="line"><span class="comment">// 传入参数无线拓展 =&gt; 返回函数本身</span></span><br><span class="line"><span class="comment">// 主功能 =&gt; 累加</span></span><br><span class="line"><span class="comment">// 输出 支持从函数到产出的转换</span></span><br><span class="line"><span class="keyword">const</span> add = <span class="keyword">function</span> (<span class="params">...nums</span>) &#123;</span><br><span class="line">	<span class="comment">// input</span></span><br><span class="line">	<span class="keyword">let</span> args = <span class="title class_">Array</span>.<span class="property"><span class="keyword">prototype</span></span>.<span class="property">slice</span>.<span class="title function_">call</span>(<span class="variable language_">arguments</span>)</span><br><span class="line">	<span class="comment">// 内层</span></span><br><span class="line">	<span class="keyword">let</span> inner = <span class="keyword">function</span> (<span class="params">...nums</span>) &#123;</span><br><span class="line">		args.<span class="title function_">push</span>(...<span class="variable language_">arguments</span>)</span><br><span class="line">		<span class="keyword">return</span> inner</span><br><span class="line">	&#125;</span><br><span class="line">	inner.<span class="property">toString</span> = <span class="keyword">function</span> (<span class="params"></span>) &#123;</span><br><span class="line">		<span class="keyword">return</span> args.<span class="title function_">reduce</span>(<span class="function">(<span class="params">prev, cur</span>) =&gt;</span> &#123;</span><br><span class="line">			<span class="keyword">return</span> prev + cur</span><br><span class="line">		&#125;)</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="keyword">return</span> inner</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<ol start="2">
<li>流水线 - 组装函数</li>
</ol>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> <span class="title function_">compose</span> = (<span class="params">f, g</span>) =&gt; <span class="function">(<span class="params">x</span>) =&gt;</span> <span class="title function_">f</span>(<span class="title function_">g</span>(x))</span><br><span class="line"></span><br><span class="line"><span class="keyword">const</span> <span class="title function_">sum1</span> = (<span class="params">x</span>) =&gt; x + <span class="number">1</span></span><br><span class="line"><span class="keyword">const</span> <span class="title function_">sum2</span> = (<span class="params">x</span>) =&gt; x + <span class="number">2</span></span><br><span class="line"><span class="keyword">const</span> sum12 = <span class="title function_">compose</span>(sum1, sum2)</span><br><span class="line"><span class="title function_">sum12</span>(<span class="number">1</span>)</span><br></pre></td></tr></table></figure>

<h2 id="常见的三方库"><a href="#常见的三方库" class="headerlink" title="常见的三方库"></a>常见的三方库</h2><p>lodash</p>
<p>rxjs</p>

      
    </div>

    
    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://jjbond.cn/posts/15523.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.png">
      <meta itemprop="name" content="右眼">
      <meta itemprop="description" content="任何时间 任何地点<br>超级侦探 认真办案">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="吉吉邦德">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/posts/15523.html" class="post-title-link" itemprop="url">浏览器 Browser</a>
        </h2>

        <div class="post-meta">
          
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2024-03-25 14:48:56" itemprop="dateCreated datePublished" datetime="2024-03-25T14:48:56+08:00">2024-03-25</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2024-04-15 15:42:55" itemprop="dateModified" datetime="2024-04-15T15:42:55+08:00">2024-04-15</time>
              </span>

          <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="far fa-file-word"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>2.8k</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="far fa-clock"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>3 分钟</span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h2 id="概念"><a href="#概念" class="headerlink" title="概念"></a>概念</h2><p>JavaScript 在浏览器下一般三部分组成：<br>ECMAscript DOM BOM</p>
<p><strong>W3C</strong> 是非标准化组织，制定浏览器规范</p>
<p><strong>ECMAscript</strong>：是一种标准，用来标准化 JavaScript 语言，es6、es7 都是其标准化的产物。在浏览器中以 V8，JSCore 等引擎解析。</p>
<p><strong>MDN</strong>：Mozilla Developer Network 规范文档</p>
          <!--noindex-->
            <div class="post-button">
              <a class="btn" href="/posts/15523.html#more" rel="contents">
                阅读全文 &raquo;
              </a>
            </div>
          <!--/noindex-->
        
      
    </div>

    
    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://jjbond.cn/posts/63534.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.png">
      <meta itemprop="name" content="右眼">
      <meta itemprop="description" content="任何时间 任何地点<br>超级侦探 认真办案">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="吉吉邦德">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/posts/63534.html" class="post-title-link" itemprop="url">test</a>
        </h2>

        <div class="post-meta">
          
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2024-03-17 13:27:33" itemprop="dateCreated datePublished" datetime="2024-03-17T13:27:33+08:00">2024-03-17</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2024-04-15 15:42:55" itemprop="dateModified" datetime="2024-04-15T15:42:55+08:00">2024-04-15</time>
              </span>

          <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="far fa-file-word"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>4</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="far fa-clock"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>1 分钟</span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <p>test</p>

      
    </div>

    
    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://jjbond.cn/posts/38044.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.png">
      <meta itemprop="name" content="右眼">
      <meta itemprop="description" content="任何时间 任何地点<br>超级侦探 认真办案">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="吉吉邦德">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/posts/38044.html" class="post-title-link" itemprop="url">vue-cli 详解</a>
        </h2>

        <div class="post-meta">
          
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2024-01-25 16:40:22" itemprop="dateCreated datePublished" datetime="2024-01-25T16:40:22+08:00">2024-01-25</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2024-04-15 15:42:55" itemprop="dateModified" datetime="2024-04-15T15:42:55+08:00">2024-04-15</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Vue/" itemprop="url" rel="index"><span itemprop="name">Vue</span></a>
                </span>
            </span>

          <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="far fa-file-word"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>1.7k</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="far fa-clock"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>2 分钟</span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <blockquote>
<p><strong>vue-cli</strong></p>
<ul>
<li>基础:用于生成项目文件体系的搭建 + 用户交互</li>
<li>metadata 配置(元数据)</li>
<li>parser &amp; render</li>
</ul>
</blockquote>
<h2 id="vue-cli-2-x-x"><a href="#vue-cli-2-x-x" class="headerlink" title="vue-cli_2.x.x"></a>vue-cli_2.x.x</h2><h3 id="bin-vue-init-前置工作"><a href="#bin-vue-init-前置工作" class="headerlink" title="&#x2F;bin&#x2F;vue-init 前置工作"></a>&#x2F;bin&#x2F;vue-init 前置工作</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 下载远程仓库 =&gt; 远程拉去github内的配置</span></span><br><span class="line"><span class="keyword">const</span> download = <span class="built_in">require</span>(<span class="string">&#x27;download-git-repo&#x27;</span>)</span><br><span class="line"><span class="comment">// 命令行处理工具</span></span><br><span class="line"><span class="keyword">const</span> program = <span class="built_in">require</span>(<span class="string">&#x27;commander&#x27;</span>)</span><br><span class="line"><span class="comment">// node下的文件操作系统中的existsSync - 监测是否存在该路径</span></span><br><span class="line"><span class="keyword">const</span> exists = <span class="built_in">require</span>(<span class="string">&#x27;fs&#x27;</span>).<span class="property">existsSync</span></span><br><span class="line"><span class="comment">// node自带的拼接路径的模块</span></span><br><span class="line"><span class="keyword">const</span> path = <span class="built_in">require</span>(<span class="string">&#x27;path&#x27;</span>)</span><br><span class="line"><span class="comment">// 命令行中的加载效果</span></span><br><span class="line"><span class="keyword">const</span> ora = <span class="built_in">require</span>(<span class="string">&#x27;ora&#x27;</span>)</span><br><span class="line"><span class="comment">// 获取用户根目录</span></span><br><span class="line"><span class="keyword">const</span> home = <span class="built_in">require</span>(<span class="string">&#x27;user-home&#x27;</span>)</span><br><span class="line"><span class="comment">// 绝对路径替换为波浪号</span></span><br><span class="line"><span class="keyword">const</span> tildify = <span class="built_in">require</span>(<span class="string">&#x27;tildify&#x27;</span>)</span><br><span class="line"><span class="comment">// 高亮</span></span><br><span class="line"><span class="keyword">const</span> chalk = <span class="built_in">require</span>(<span class="string">&#x27;chalk&#x27;</span>)</span><br><span class="line"><span class="comment">// **important** 用户与脚本命令行的交互 | 面试</span></span><br><span class="line"><span class="keyword">const</span> inquirer = <span class="built_in">require</span>(<span class="string">&#x27;inquirer&#x27;</span>)</span><br><span class="line"><span class="comment">// rm -rf js版本</span></span><br><span class="line"><span class="keyword">const</span> rm = <span class="built_in">require</span>(<span class="string">&#x27;rimraf&#x27;</span>).<span class="property">sync</span></span><br></pre></td></tr></table></figure>

<h4 id="面试题：如何使用本地模板，预设模板-而不是-github？"><a href="#面试题：如何使用本地模板，预设模板-而不是-github？" class="headerlink" title="面试题：如何使用本地模板，预设模板 而不是 github？"></a>面试题：如何使用本地模板，预设模板 而不是 github？</h4><p>使用 <strong>–offline</strong></p>
<h4 id="如何获取用户参数"><a href="#如何获取用户参数" class="headerlink" title="如何获取用户参数"></a>如何获取用户参数</h4><blockquote>
<p>vue init webpack zhaowa-app</p>
</blockquote>
<p>program.args[0] &#x3D;&gt; ‘webpack’<br>&#x2F;&#x2F; 是否包含斜杠 &#x3D;&gt; 路径层级 &#x3D;&gt;非默认预制模板<br>const hasSlash &#x3D; template.indexOf(‘&#x2F;‘)&gt;-1</p>
<p>&#x2F;&#x2F; 项目名称<br>rawName &#x3D; program.args[1]</p>
<p>&#x2F;&#x2F;输入是否为空 &#x3D;&gt; 是否以当前文件目录作为项目根目录<br>const inPlace &#x3D; !rawName || ‘.’</p>
<p>&#x2F;&#x2F;调整当前目录作为构建目录的根路径<br>const name &#x3D; inPlace ….</p>
<p>&#x2F;&#x2F;本地目录模板仓库路径拼接 &#x2F;zhaowa&#x2F;.vue-templates&#x2F;webpack<br>const tmp &#x3D; path.join(home,’…’)</p>
<h3 id="lib-generate-js"><a href="#lib-generate-js" class="headerlink" title="&#x2F;lib&#x2F;generate.js"></a>&#x2F;lib&#x2F;generate.js</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 静态网页文件生成器</span></span><br><span class="line"><span class="keyword">const</span> <span class="title class_">Metalsmith</span></span><br><span class="line"><span class="comment">// 模板引擎</span></span><br><span class="line"><span class="keyword">const</span> <span class="title class_">Handlebars</span></span><br><span class="line"><span class="comment">// 多条件匹配工具</span></span><br><span class="line"><span class="keyword">const</span> multimatch</span><br></pre></td></tr></table></figure>

<h3 id="lib-ask-js"><a href="#lib-ask-js" class="headerlink" title="&#x2F;lib&#x2F;ask.js"></a>&#x2F;lib&#x2F;ask.js</h3><p>解析传进来的模板有哪些要询问的</p>
<p>inquirer.prompt</p>
<h3 id="lib-filter-js-过滤不需要的"><a href="#lib-filter-js-过滤不需要的" class="headerlink" title="&#x2F;lib&#x2F;filter.js 过滤不需要的"></a>&#x2F;lib&#x2F;filter.js 过滤不需要的</h3><h2 id="vue-cli-3-x-x"><a href="#vue-cli-3-x-x" class="headerlink" title="vue-cli_3.x.x"></a>vue-cli_3.x.x</h2><h3 id="lib-create-js"><a href="#lib-create-js" class="headerlink" title="&#x2F;lib&#x2F;create.js"></a>&#x2F;lib&#x2F;create.js</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> creator = <span class="keyword">new</span> <span class="title class_">Creator</span>(name, targetDir, <span class="title function_">getPromptModules</span>())</span><br><span class="line"><span class="keyword">await</span> creator.<span class="title function_">create</span>(options)</span><br></pre></td></tr></table></figure>

<h3 id="lib-Creator-js"><a href="#lib-Creator-js" class="headerlink" title="&#x2F;lib&#x2F;Creator.js"></a>&#x2F;lib&#x2F;Creator.js</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="variable language_">module</span>.<span class="property">exports</span> = <span class="keyword">class</span> <span class="title class_">Creator</span> <span class="keyword">extends</span> <span class="title class_ inherited__">EventEmitter</span> &#123;&#125;</span><br></pre></td></tr></table></figure>

<h2 id="流程"><a href="#流程" class="headerlink" title="流程"></a>流程</h2><p>用户创建指令 -&gt; 创建参数解析 -&gt; 加载模板(远端&#x2F;本地) – prompts –&gt; 处理文件路径 -&gt; 文件层级处理 -&gt; 文件模板渲染(plugins) -&gt; 产出包</p>
<p>如何书写 node 脚本工具</p>

      
    </div>

    
    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://jjbond.cn/posts/54268.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.png">
      <meta itemprop="name" content="右眼">
      <meta itemprop="description" content="任何时间 任何地点<br>超级侦探 认真办案">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="吉吉邦德">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/posts/54268.html" class="post-title-link" itemprop="url">vue3.x 源码</a>
        </h2>

        <div class="post-meta">
          
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2024-01-16 15:33:05" itemprop="dateCreated datePublished" datetime="2024-01-16T15:33:05+08:00">2024-01-16</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2024-04-15 15:42:55" itemprop="dateModified" datetime="2024-04-15T15:42:55+08:00">2024-04-15</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Vue/" itemprop="url" rel="index"><span itemprop="name">Vue</span></a>
                </span>
            </span>

          <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="far fa-file-word"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>3.9k</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="far fa-clock"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>4 分钟</span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h2 id="vue2-存在的问题"><a href="#vue2-存在的问题" class="headerlink" title="vue2 存在的问题"></a>vue2 存在的问题</h2><ul>
<li>代码结构：以整体的包为形式存在</li>
<li>性能优化的空间：ObjectDefineProperty 对象的方法，要对数组进行操作的话需要再自己封装一层，且所有值都是响应式的(性能损耗)</li>
<li>选项式的配置模式：不好维护庞大的项目，可维护性</li>
<li>浏览器真的需要老版本吗</li>
</ul>
<h2 id="vue3-的问题"><a href="#vue3-的问题" class="headerlink" title="vue3 的问题"></a>vue3 的问题</h2><ul>
<li>太多的 <strong>breaking changes</strong> 太多不兼容的内容</li>
<li>生态影响</li>
<li>发布节奏太快
          <!--noindex-->
            <div class="post-button">
              <a class="btn" href="/posts/54268.html#more" rel="contents">
                阅读全文 &raquo;
              </a>
            </div>
          <!--/noindex-->
        
      
    </div>

    
    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://jjbond.cn/posts/5805.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.png">
      <meta itemprop="name" content="右眼">
      <meta itemprop="description" content="任何时间 任何地点<br>超级侦探 认真办案">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="吉吉邦德">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/posts/5805.html" class="post-title-link" itemprop="url">vue2.x 源码</a>
        </h2>

        <div class="post-meta">
          
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2024-01-15 15:09:23" itemprop="dateCreated datePublished" datetime="2024-01-15T15:09:23+08:00">2024-01-15</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2024-04-15 15:42:55" itemprop="dateModified" datetime="2024-04-15T15:42:55+08:00">2024-04-15</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Vue/" itemprop="url" rel="index"><span itemprop="name">Vue</span></a>
                </span>
            </span>

          <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="far fa-file-word"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>450</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="far fa-clock"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>1 分钟</span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <h1 id="引言"><a href="#引言" class="headerlink" title="引言"></a>引言</h1><blockquote>
<p><strong>面试</strong>：观察者模式 &amp; 发布订阅<br>观察者模式：(观察者，被观察者) 中心一对多 + 系统单点的灵活和拓展<br>发布订阅：(发布者，订阅者，发布订阅中心) 调度中心 &#x3D;&gt; 将注册列表<em>遍历</em>然后发布给订阅者</p>
</blockquote>
<p>view -&gt; listner&#x2F;binding&#x2F;处理内容 -&gt; model</p>
<blockquote>
<p><strong>追问</strong>：要实现这些方式，如何双向绑定</p>
</blockquote>
<pre><code>数据监听器Observe     &lt;----     mvvm
            |                    |
            |                    |
            V                    |
通知数据变化Dep                   |
            | ↑                  |
            | 添加订阅            |
            V |                  |
连接双方的桥梁watcher&lt;---   代码生成(指令归纳)
            |          |         |
            |   绑定函数/订阅数据  |
         更新视图       |         |
            |           -------- |
            V                    V
           view   &lt;—更新视图—  compiler
</code></pre>
<p>源码 -&gt; 原理 -&gt; 他人源码思路</p>
          <!--noindex-->
            <div class="post-button">
              <a class="btn" href="/posts/5805.html#more" rel="contents">
                阅读全文 &raquo;
              </a>
            </div>
          <!--/noindex-->
        
      
    </div>

    
    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://jjbond.cn/posts/10922.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.png">
      <meta itemprop="name" content="右眼">
      <meta itemprop="description" content="任何时间 任何地点<br>超级侦探 认真办案">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="吉吉邦德">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/posts/10922.html" class="post-title-link" itemprop="url">vue进阶</a>
        </h2>

        <div class="post-meta">
          
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2024-01-08 14:21:25" itemprop="dateCreated datePublished" datetime="2024-01-08T14:21:25+08:00">2024-01-08</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2024-04-15 15:42:55" itemprop="dateModified" datetime="2024-04-15T15:42:55+08:00">2024-04-15</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Vue/" itemprop="url" rel="index"><span itemprop="name">Vue</span></a>
                </span>
            </span>

          <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="far fa-file-word"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>2.2k</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="far fa-clock"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>2 分钟</span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <span id="more"></span>

<ul>
<li><a href="#vue-%E8%BF%9B%E9%98%B6">vue 进阶</a><ul>
<li><a href="#%E7%89%B9%E5%BE%81%E4%B8%80%E6%A8%A1%E5%9D%97%E5%8C%96--vue-template-compiler-%E7%BC%96%E8%AF%91%E6%80%81%E6%8A%8A-template-%E8%BD%AC%E6%8D%A2%E6%88%90-render">特征一：模块化 &#x3D;&gt; vue-template-compiler （编译态把 template 转换成 render()）</a><ul>
<li><a href="#%E6%8F%92%E6%A7%BD---%E9%9D%A2%E8%AF%95%E8%80%83%E5%AF%9F%E7%82%B9--%E5%AF%B9%E6%AF%94%E5%BD%A2%E5%BC%8F">插槽 - 面试考察点 &#x3D;&gt; 对比形式</a><ul>
<li><a href="#%E9%BB%98%E8%AE%A4%E6%8F%92%E6%A7%BD">默认插槽</a></li>
<li><a href="#%E5%85%B7%E5%90%8D%E6%8F%92%E6%A7%BD">具名插槽</a></li>
<li><a href="#%E4%BD%9C%E7%94%A8%E5%9F%9F%E6%8F%92%E6%A7%BD">作用域插槽</a></li>
</ul>
</li>
<li><a href="#%E6%A8%A1%E6%9D%BF%E7%9A%84%E4%BA%8C%E6%AC%A1%E5%8A%A0%E5%B7%A5">模板的二次加工</a></li>
<li><a href="#jsx-%E6%9B%B4%E8%87%AA%E7%94%B1%E7%9A%84-all-in-js">jsx 更自由的 all in js</a></li>
</ul>
</li>
<li><a href="#%E7%89%B9%E5%BE%81%E4%BA%8C%E7%BB%84%E4%BB%B6%E5%8C%96">特征二：组件化</a><ul>
<li><a href="#%E6%B7%B7%E5%85%A5-mixin---%E9%80%BB%E8%BE%91%E6%B7%B7%E5%85%A5">混入 mixin - 逻辑混入</a></li>
<li><a href="#%E7%BB%A7%E6%89%BF%E6%8B%93%E5%B1%95-extends---%E9%80%BB%E8%BE%91%E4%B8%8A%E7%9A%84%E5%85%B1%E5%90%8C%E6%8B%93%E5%B1%95">继承拓展 extends - 逻辑上的共同拓展</a></li>
<li><a href="#%E6%8F%92%E4%BB%B6%E7%B3%BB%E7%BB%9F">插件系统</a></li>
<li><a href="#vue-3---compositionapi">Vue 3 - compositionAPI</a></li>
</ul>
</li>
</ul>
</li>
</ul>
<h1 id="vue-进阶"><a href="#vue-进阶" class="headerlink" title="vue 进阶"></a>vue 进阶</h1><h2 id="特征一：模块化-vue-template-compiler-（编译态把-template-转换成-render-）"><a href="#特征一：模块化-vue-template-compiler-（编译态把-template-转换成-render-）" class="headerlink" title="特征一：模块化 &#x3D;&gt; vue-template-compiler （编译态把 template 转换成 render()）"></a>特征一：模块化 &#x3D;&gt; vue-template-compiler （编译态把 template 转换成 render()）</h2><h3 id="插槽-面试考察点-对比形式"><a href="#插槽-面试考察点-对比形式" class="headerlink" title="插槽 - 面试考察点 &#x3D;&gt; 对比形式"></a>插槽 - 面试考察点 &#x3D;&gt; 对比形式</h3><h4 id="默认插槽"><a href="#默认插槽" class="headerlink" title="默认插槽"></a>默认插槽</h4><p>组件外部维护参数与结构，内部安排位置摆放</p>
<ul>
<li>追问 &#x3D;&gt; 默认插槽的实现方式》 &#x3D;&gt; 插槽聚合（渲染在一个地方 顺序渲染）</li>
<li>追问 &#x3D;&gt; 多个插槽会以何种形态渲染（合并） &#x3D;&gt; 如何放在不同的地方?</li>
</ul>
<h4 id="具名插槽"><a href="#具名插槽" class="headerlink" title="具名插槽"></a>具名插槽</h4><p>用 name 表示当前身份，从而在组件内部区分</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 父组件</span></span><br><span class="line">&lt;template v-<span class="attr">slot</span>:header&gt;&#123;&#123;header&#125;&#125;&lt;/template&gt;</span><br><span class="line"><span class="language-xml"><span class="tag">&lt;<span class="name">template</span> #<span class="attr">header</span>&gt;</span>&#123;&#123;header&#125;&#125;<span class="tag">&lt;/<span class="name">template</span>&gt;</span></span></span><br><span class="line"><span class="comment">// 子组件</span></span><br><span class="line"><span class="language-xml"><span class="tag">&lt;<span class="name">slot</span> <span class="attr">name</span>=<span class="string">&quot;header&quot;</span>/&gt;</span></span></span><br></pre></td></tr></table></figure>

<ul>
<li>具名插槽可以在指定位置分开布局 &#x3D;&gt; 原理：name 索引了一段单个解析的命名空间，node 独立由这个单个解析空间进行渲染</li>
<li>追问 &#x3D;&gt; 以 node 渲染为单位 &#x3D;&gt; 混合式传参？</li>
</ul>
<h4 id="作用域插槽"><a href="#作用域插槽" class="headerlink" title="作用域插槽"></a>作用域插槽</h4><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 父组件</span></span><br><span class="line">&lt;template slot=<span class="string">&quot;content&quot;</span> slot-scope=<span class="string">&quot;&#123;slotProps&#125;&quot;</span>&gt;&#123;&#123;slotProps&#125;&#125; - &#123;&#123;others&#125;&#125;&lt;/template&gt;</span><br><span class="line"><span class="comment">// 子组件</span></span><br><span class="line"><span class="language-xml"><span class="tag">&lt;<span class="name">slot</span> <span class="attr">name</span>=<span class="string">&quot;content&quot;</span> <span class="attr">:slotProps</span>=<span class="string">&#123;&#123;slotProps&#125;&#125;/</span>&gt;</span></span></span><br><span class="line"><span class="title function_">data</span>(<span class="params"></span>)&#123;</span><br><span class="line">  <span class="keyword">return</span>&#123;</span><br><span class="line">    <span class="attr">slotProps</span>:<span class="string">&#x27;slot props&#x27;</span></span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p>外部可以做结构勾勒和参数合并，内部也可以提供参数混合</p>
<ul>
<li>父子参数共同向 slot 传递</li>
</ul>
<h3 id="模板的二次加工"><a href="#模板的二次加工" class="headerlink" title="模板的二次加工"></a>模板的二次加工</h3><ol>
<li>watch | computed &#x3D;&gt; 配置里声明和书写</li>
<li>其余方法：<br>a. 函数 - 过滤器 | 独立管道符 &#x3D;&gt; 管道符和函数有什么区别？| 管道符能拿到实例嘛？ (<strong>不能！</strong>)<br>b. v-html &#x3D;&gt; 递归调用渲染 node &#x3D;&gt; 安全性风险<br>c. 利用组件形式</li>
</ol>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 过滤器</span></span><br><span class="line"><span class="comment">// template</span></span><br><span class="line">&lt;p&gt;&#123;&#123;money | moneyFilter&#125;&#125;&lt;/p&gt;</span><br><span class="line"><span class="comment">// script</span></span><br><span class="line"><span class="title function_">data</span>(<span class="params"></span>)&#123;</span><br><span class="line"></span><br><span class="line">&#125;,</span><br><span class="line"><span class="attr">filters</span>:&#123;</span><br><span class="line">  <span class="title function_">moneyFilter</span>(<span class="params">param</span>)&#123;</span><br><span class="line">    <span class="variable language_">console</span>.<span class="title function_">log</span>(<span class="variable language_">this</span>)</span><br><span class="line">    <span class="keyword">return</span> param &gt; <span class="number">99</span> ? <span class="number">99</span> : param</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<h3 id="jsx-更自由的-all-in-js"><a href="#jsx-更自由的-all-in-js" class="headerlink" title="jsx 更自由的 all in js"></a>jsx 更自由的 all in js</h3><ul>
<li>面试题：<ol>
<li>语法糖的实现</li>
<li>jsx 的优点和劣势<ol>
<li>vue 编译：（_beforeMount_）template &#x3D;&gt; render() &#x3D;&gt; （_Mounted_）vm.render()</li>
<li>template 编译，带有 dom 渲染优化，性能节约</li>
<li>直接写 render 函数不受 vue 语法限制，不依赖于 vue 的 api</li>
</ol>
</li>
</ol>
</li>
</ul>
<h2 id="特征二：组件化"><a href="#特征二：组件化" class="headerlink" title="特征二：组件化"></a>特征二：组件化</h2><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="title class_">Vue</span>.<span class="title function_">component</span>(<span class="string">&#x27;component&#x27;</span>, &#123;</span><br><span class="line">	<span class="attr">template</span>: <span class="string">&#x27;&lt;h1&gt;&lt;/h1&gt;&#x27;</span>,</span><br><span class="line">&#125;)</span><br><span class="line"><span class="keyword">new</span> <span class="title class_">Vue</span>(&#123;</span><br><span class="line">	<span class="attr">el</span>: <span class="string">&#x27;#app&#x27;</span>,</span><br><span class="line">&#125;)</span><br></pre></td></tr></table></figure>

<ul>
<li><ol>
<li>抽象复用</li>
</ol>
</li>
<li><ol start="2">
<li>精简 &amp; 聚合</li>
</ol>
</li>
</ul>
<h3 id="混入-mixin-逻辑混入"><a href="#混入-mixin-逻辑混入" class="headerlink" title="混入 mixin - 逻辑混入"></a>混入 mixin - 逻辑混入</h3><ul>
<li><ol>
<li>应用：公共逻辑功能的继承</li>
</ol>
</li>
<li><ol start="2">
<li>面试：合并策略 生命周期</li>
</ol>
<ul>
<li>变量补充形式上 &#x3D;&gt; 额外补充、不会覆盖</li>
<li>生命周期 &#x3D;&gt; minxin 在引用该 mixin 组件之前执行</li>
<li>同样引用的两个 mixin &#x3D;&gt; 根据引用顺序安排加载顺序</li>
</ul>
</li>
</ul>
<h3 id="继承拓展-extends-逻辑上的共同拓展"><a href="#继承拓展-extends-逻辑上的共同拓展" class="headerlink" title="继承拓展 extends - 逻辑上的共同拓展"></a>继承拓展 extends - 逻辑上的共同拓展</h3><ul>
<li><ol>
<li>核心逻辑的继承</li>
</ol>
</li>
<li><ol start="2">
<li>合并策略</li>
</ol>
<ul>
<li>不会覆盖</li>
<li>生命周期 &#x3D;&gt; 不论是业务代码还是 mixin 都在 extents 生命周期之后</li>
<li>只有一个</li>
</ul>
</li>
</ul>
<h3 id="插件系统"><a href="#插件系统" class="headerlink" title="插件系统"></a>插件系统</h3><figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> element <span class="keyword">from</span> <span class="string">&#x27;element&#x27;</span></span><br><span class="line"></span><br><span class="line"><span class="comment">//Vue.use(element)</span></span><br><span class="line"><span class="title function_">createApp</span>(app).<span class="title function_">use</span>(element, &#123;</span><br><span class="line">	<span class="attr">isA</span>: <span class="literal">true</span>,</span><br><span class="line">&#125;)</span><br><span class="line"><span class="comment">// =&gt; install:(()=&gt;&#123;&#125;)</span></span><br><span class="line"></span><br><span class="line"><span class="comment">// vue.prototype.$abc =&gt; this.$abc</span></span><br><span class="line"><span class="comment">// app.globalProperties.$abc</span></span><br></pre></td></tr></table></figure>

<h3 id="Vue-3-compositionAPI"><a href="#Vue-3-compositionAPI" class="headerlink" title="Vue 3 - compositionAPI"></a>Vue 3 - compositionAPI</h3>
      
    </div>

    
    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  

      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="https://jjbond.cn/posts/45434.html">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.png">
      <meta itemprop="name" content="右眼">
      <meta itemprop="description" content="任何时间 任何地点<br>超级侦探 认真办案">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="吉吉邦德">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">
          
            <a href="/posts/45434.html" class="post-title-link" itemprop="url">vue 基础 v5</a>
        </h2>

        <div class="post-meta">
          
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2024-01-06 20:07:53" itemprop="dateCreated datePublished" datetime="2024-01-06T20:07:53+08:00">2024-01-06</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2024-04-15 15:42:55" itemprop="dateModified" datetime="2024-04-15T15:42:55+08:00">2024-04-15</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/Vue/" itemprop="url" rel="index"><span itemprop="name">Vue</span></a>
                </span>
            </span>

          <br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="far fa-file-word"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>1.6k</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="far fa-clock"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>1 分钟</span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
          <span id="more"></span>

<ul>
<li><a href="#vue-%E5%9F%BA%E7%A1%80">vue 基础</a><ul>
<li><a href="#%E7%90%86%E8%AE%BA">理论</a><ul>
<li><a href="#%E9%9D%A2%E8%AF%95%E9%A2%98%E5%AF%B9-mvvm-%E7%9A%84%E4%BA%86%E8%A7%A3">面试题：对 MVVM 的了解</a></li>
</ul>
</li>
<li><a href="#%E5%86%99%E6%B3%95">写法</a><ul>
<li><a href="#vue-%E5%A6%82%E4%BD%95%E5%88%A9%E7%94%A8-mvvm-%E5%BC%80%E5%8F%91">vue 如何利用 mvvm 开发?</a></li>
</ul>
</li>
<li><a href="#%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F">生命周期</a><ul>
<li><a href="#%E9%9D%A2%E8%AF%95%E9%A2%98vue-%E7%9A%84%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F">面试题：vue 的生命周期</a></li>
</ul>
</li>
<li><a href="#%E7%9B%91%E5%90%AC">监听</a><ul>
<li><a href="#%E9%9D%A2%E8%AF%95%E9%A2%98computed-%E5%92%8C-watch">面试题：computed 和 watch</a></li>
</ul>
</li>
<li><a href="#%E6%8C%87%E4%BB%A4--%E6%9D%A1%E4%BB%B6">指令 &amp; 条件</a><ul>
<li><a href="#%E6%9D%A1%E4%BB%B6">条件</a></li>
<li><a href="#v-for--v-if-%E5%9C%A8%E5%90%8C%E4%B8%80%E8%8A%82%E7%82%B9%E4%BD%BF%E7%94%A8%E6%97%B6">v-for &amp; v-if 在同一节点使用时</a></li>
<li><a href="#v-model-v-once-v-text-v-html-v-bind">v-model v-once v-text v-html v-bind</a></li>
<li><a href="#%E8%87%AA%E5%AE%9A%E4%B9%89%E6%8C%87%E4%BB%A4">自定义指令</a></li>
</ul>
</li>
<li><a href="#%E4%BA%8B%E4%BB%B6---v-on">事件 - v-on</a><ul>
<li><a href="#%E4%BF%AE%E9%A5%B0%E7%AC%A6">修饰符</a></li>
<li><a href="#%E4%BA%8B%E4%BB%B6%E7%9A%84%E8%AE%BE%E8%AE%A1---%E4%B8%BA%E4%BD%95-vue-%E6%8A%8A%E4%BA%8B%E4%BB%B6%E8%AE%BE%E8%AE%A1%E5%9C%A8%E6%A8%A1%E6%9D%BF%E4%B8%8A%E8%80%8C%E4%B8%8D%E6%98%AF-js-%E4%B8%AD">事件的设计 - 为何 vue 把事件设计在模板上而不是 js 中</a></li>
</ul>
</li>
<li><a href="#%E7%BB%84%E4%BB%B6%E5%8C%96">组件化</a><ul>
<li><a href="#%E4%B8%80%E8%88%AC%E7%BB%84%E4%BB%B6--%E5%8A%A8%E6%80%81%E7%BB%84%E4%BB%B6--%E6%8F%92%E4%BB%B6">一般组件 + 动态组件 &#x3D;&gt; 插件</a></li>
</ul>
</li>
</ul>
</li>
</ul>
<h2 id="vue-基础"><a href="#vue-基础" class="headerlink" title="vue 基础"></a>vue 基础</h2><h3 id="理论"><a href="#理论" class="headerlink" title="理论"></a>理论</h3><h4 id="面试题：对-MVVM-的了解"><a href="#面试题：对-MVVM-的了解" class="headerlink" title="面试题：对 MVVM 的了解"></a>面试题：对 MVVM 的了解</h4><ul>
<li>Web 应用发展史<ol>
<li>语义化模板</li>
<li>MVC - model view controller</li>
<li>MVVM - model view viewModel<ol>
<li>数据本身会通过 model 挂在在 viewModel，vm 会劫持数据并同步至渲染层</li>
<li>视图层发生外部变化，会同样回调给 vw，返回给 model</li>
</ol>
</li>
</ol>
</li>
</ul>
<h3 id="写法"><a href="#写法" class="headerlink" title="写法"></a>写法</h3><h4 id="vue-如何利用-mvvm-开发"><a href="#vue-如何利用-mvvm-开发" class="headerlink" title="vue 如何利用 mvvm 开发?"></a>vue 如何利用 mvvm 开发?</h4><p>数据双向绑定</p>
<ol>
<li>利用花括号，构筑了数据与 vm 的双向绑定关系 &#x3D;》 buildTemplate | compile</li>
<li>通过视图绑定监听事件来处理数据 &#x3D;》v-model &#x3D;&#x3D;&#x3D; :value @input &#x3D;&gt; 节点处理流程</li>
</ol>
<p><strong>buildTemplate &#x3D;》 render()</strong></p>
<h3 id="生命周期"><a href="#生命周期" class="headerlink" title="生命周期"></a>生命周期</h3><h4 id="面试题：vue-的生命周期"><a href="#面试题：vue-的生命周期" class="headerlink" title="面试题：vue 的生命周期"></a>面试题：vue 的生命周期</h4><p>创建阶段: beforeCreate &#x3D;&gt; created &#x3D;&gt; beforeMount &#x3D;&gt; mounted</p>
<p>更新阶段: beforeUpdate &#x3D;&gt; updated</p>
<p>销毁阶段: beforeDestroy &#x3D;》 destroyed</p>
<p><font color=LightSkyBlue>beforeCreate</font>： new Vue() - 创建实例阶段<br><font color=LightSkyBlue>created</font>: data | props | method | computed - 数据创建</p>
<p><font color=orange>beforeMount</font>: vDom(虚拟节点) - 数据操作以及虚拟 dom 的变化 但不能涉及 dom<br><font color=orange>mounted</font>: Dom 更新</p>
<p><font color=CadetBlue>beforeUpdate</font>： vDom - 完成更新，dom 还未更新<br><font color=CadetBlue>updated</font>： dom 完成更新 &#x3D;》 谨慎做更新数据操作</p>
<p><font color=Green>beforeDestroy</font>：实例尚未销毁 - 清空 eventBus setTimeOut<br><font color=Green>destroyed</font>：完全销毁</p>
<p>补充：key &#x3D;》 diff &#x3D;》 dom diff &#x3D;》 节点 id</p>
<h3 id="监听"><a href="#监听" class="headerlink" title="监听"></a>监听</h3><h4 id="面试题：computed-和-watch"><a href="#面试题：computed-和-watch" class="headerlink" title="面试题：computed 和 watch"></a>面试题：computed 和 watch</h4><p>相同点：</p>
<ol>
<li><strong>基于 vue 的依赖收集机制</strong>进行采集</li>
<li>都是被依赖的变化所触发，从而进行处理回调</li>
</ol>
<p>不同点：</p>
<ol>
<li>入&#x2F;出：computed 多入单出，watch 单入多出</li>
<li>性能：computed 存在缓存，不收调用次数的性能损耗；watch 只在监听的值变化时，不包含生成 immediate</li>
<li>computed 关注结果，watch 关注过程</li>
</ol>
<p>问：computed 缓存和响应式如何实现的?</p>
<p>完整过程：</p>
<ol>
<li>流程：new Vue() &#x3D;&gt; 初始化 computed(initState) &#x3D;&gt; createComputedGetter(key) &#x3D;&gt; mount</li>
<li>劫持：getter 属性变化区分是否是最新状态 dirty</li>
<li>target depend &lt;&#x3D;&#x3D;&gt; 原值和依赖之间的关系链</li>
</ol>
<h3 id="指令-条件"><a href="#指令-条件" class="headerlink" title="指令 &amp; 条件"></a>指令 &amp; 条件</h3><h4 id="条件"><a href="#条件" class="headerlink" title="条件"></a>条件</h4><p>v-if | v-show<br>v-else | v-else-if</p>
<p>v-for</p>
<h4 id="v-for-v-if-在同一节点使用时"><a href="#v-for-v-if-在同一节点使用时" class="headerlink" title="v-for &amp; v-if 在同一节点使用时"></a>v-for &amp; v-if 在同一节点使用时</h4><p>vue2.x v-for 会优先作用<br>vue3.x v-if 总是优先于 v-for</p>
<h4 id="v-model-v-once-v-text-v-html-v-bind"><a href="#v-model-v-once-v-text-v-html-v-bind" class="headerlink" title="v-model v-once v-text v-html v-bind"></a>v-model v-once v-text v-html v-bind</h4><h4 id="自定义指令"><a href="#自定义指令" class="headerlink" title="自定义指令"></a>自定义指令</h4><h3 id="事件-v-on"><a href="#事件-v-on" class="headerlink" title="事件 - v-on"></a>事件 - v-on</h3><h4 id="修饰符"><a href="#修饰符" class="headerlink" title="修饰符"></a>修饰符</h4><p>.stop .prevent .once .capture .self .passive</p>
<h4 id="事件的设计-为何-vue-把事件设计在模板上而不是-js-中"><a href="#事件的设计-为何-vue-把事件设计在模板上而不是-js-中" class="headerlink" title="事件的设计 - 为何 vue 把事件设计在模板上而不是 js 中"></a>事件的设计 - 为何 vue 把事件设计在模板上而不是 js 中</h4><ol>
<li>模板定位视图绑定的触发源 + 触发源寻找触发事件的逻辑 —— 方便定位</li>
<li>js 与视图绑定解耦 —— 更便于测试隔离</li>
<li>vm 销毁，自动解绑事件 —— 便于回收</li>
</ol>
<h3 id="组件化"><a href="#组件化" class="headerlink" title="组件化"></a>组件化</h3><h4 id="一般组件-动态组件-插件"><a href="#一般组件-动态组件-插件" class="headerlink" title="一般组件 + 动态组件 &#x3D;&gt; 插件"></a>一般组件 + 动态组件 &#x3D;&gt; 插件</h4>
      
    </div>

    
    
    
    
      <footer class="post-footer">
        <div class="post-eof"></div>
      </footer>
  </article>
  
  
  


  
  <nav class="pagination">
    <span class="page-number current">1</span><a class="page-number" href="/page/2/">2</a><a class="extend next" rel="next" href="/page/2/"><i class="fa fa-angle-right" aria-label="下一页"></i></a>
  </nav>



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="右眼"
      src="/images/avatar.png">
  <p class="site-author-name" itemprop="name">右眼</p>
  <div class="site-description" itemprop="description">任何时间 任何地点<br>超级侦探 认真办案</div>
</div>


<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">18</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">6</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">7</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <a href="https://github.com/Neopo1itan/" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;Neopo1itan&#x2F;" rel="noopener" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
      <span class="links-of-author-item">
        <a href="https://weibo.com/youyan030" title="Weibo → https:&#x2F;&#x2F;weibo.com&#x2F;youyan030" rel="noopener" target="_blank"><i class="fab fa-weibo fa-fw"></i>Weibo</a>
      </span>
      <span class="links-of-author-item">
        <a href="https://steamcommunity.com/id/youyanww/" title="Steam → https:&#x2F;&#x2F;steamcommunity.com&#x2F;id&#x2F;youyanww&#x2F;" rel="noopener" target="_blank"><i class="fab fa-steam fa-fw"></i>Steam</a>
      </span>
      <span class="links-of-author-item">
        <a href="https://space.bilibili.com/895680/video" title="BiliBili → https:&#x2F;&#x2F;space.bilibili.com&#x2F;895680&#x2F;video" rel="noopener" target="_blank"><i class="fa fa-wheelchair fa-fw"></i>BiliBili</a>
      </span>
  </div>



      </div>
      
<iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width=320 height=240 src="//music.163.com/outchain/player?type=0&id=8545160772&auto=1&height=430"></iframe>
    
      <script type="text/javascript" charset="utf-8" src="/js/tagcloud.js"></script>
      <script type="text/javascript" charset="utf-8" src="/js/tagcanvas.js"></script>
        <div class="widget-wrap">
          <div id="myCanvasContainer" class="widget tagcloud">
            <canvas width="250" height="250" id="resCanvas" style="width:100%">
              <ul class="tag-list" itemprop="keywords"><li class="tag-list-item"><a class="tag-list-link" href="/tags/JS/" rel="tag">JS</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/JavaScript/" rel="tag">JavaScript</a><span class="tag-list-count">5</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/React/" rel="tag">React</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Vue/" rel="tag">Vue</a><span class="tag-list-count">5</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Web/" rel="tag">Web</a><span class="tag-list-count">15</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/nodejs/" rel="tag">nodejs</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/python/" rel="tag">python</a><span class="tag-list-count">1</span></li></ul>
            </canvas>
          </div>
        </div>
    
    </div>

  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2024</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">右眼</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-chart-area"></i>
    </span>
    <span title="站点总字数">59k</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
    <span title="站点阅读时长">53 分钟</span>
</div>
  <div class="powered-by">
    <!--由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Gemini</a> 强力驱动 -->
    <span>个人网站&nbsp&nbsp&nbsp|&nbsp&nbsp&nbsp吉吉邦德</span>
  </div>



<!--添加运行时间--> 
</br>
<span id="sitetime"></span> 
<script language=javascript> 
  function siteTime(){ 
    window.setTimeout("siteTime()", 1000); 
    var seconds = 1000; 
    var minutes = seconds * 60; 
    var hours = minutes * 60; 
    var days = hours * 24; 
    var years = days * 365; 
    var today = new Date(); 
    var todayYear = today.getFullYear(); 
    var todayMonth = today.getMonth()+1; 
    var todayDate = today.getDate(); 
    var todayHour = today.getHours(); 
    var todayMinute = today.getMinutes(); 
    var todaySecond = today.getSeconds(); 
    /* 
    Date.UTC() -- 返回date对象距世界标准时间(UTC)1970年1月1日午夜之间的毫秒数(时间戳) 
    year - 作为date对象的年份，为4位年份值 
    month - 0-11之间的整数，做为date对象的月份 
    day - 1-31之间的整数，做为date对象的天数 
    hours - 0(午夜24点)-23之间的整数，做为date对象的小时数 
    minutes - 0-59之间的整数，做为date对象的分钟数 
    seconds - 0-59之间的整数，做为date对象的秒数 
    microseconds - 0-999之间的整数，做为date对象的毫秒数 
    */ 
    var t1 = Date.UTC(2023,07,06,15,49,36); //北京时间2018-2-13 00:00:00 
    var t2 = Date.UTC(todayYear,todayMonth,todayDate,todayHour,todayMinute,todaySecond); 
    var diff = t2-t1; 
    var diffYears = Math.floor(diff/years); 
    var diffDays = Math.floor((diff/days)-diffYears*365); 
    var diffHours = Math.floor((diff-(diffYears*365+diffDays)*days)/hours); 
    var diffMinutes = Math.floor((diff-(diffYears*365+diffDays)*days-diffHours*hours)/minutes); 
    var diffSeconds = Math.floor((diff-(diffYears*365+diffDays)*days-diffHours*hours-diffMinutes*minutes)/seconds); 
    document.getElementById("sitetime").innerHTML=" 已运行"+/*diffYears+" 年 "+*/diffDays+" 天 "+diffHours+" 小时 "+diffMinutes+" 分钟 "+diffSeconds+" 秒"; 
    } 
    siteTime(); 
</script> 
<!--// 添加运行时间-->

        








      </div>
    </footer>
  </div>

  
  <script type="text/javascript" src="//cdn.bootcss.com/canvas-nest.js/1.0.0/canvas-nest.min.js"></script>
    

  
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/pjax/pjax.min.js"></script>
  <script src="//cdn.jsdelivr.net/npm/lozad@1/dist/lozad.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/pisces.js"></script>


<script src="/js/next-boot.js"></script>

  <script>
var pjax = new Pjax({
  selectors: [
    'head title',
    '#page-configurations',
    '.content-wrap',
    '.post-toc-wrap',
    '.languages',
    '#pjax'
  ],
  switches: {
    '.post-toc-wrap': Pjax.switches.innerHTML
  },
  analytics: false,
  cacheBust: false,
  scrollTo : !CONFIG.bookmark.enable
});

window.addEventListener('pjax:success', () => {
  document.querySelectorAll('script[data-pjax], script#page-configurations, #pjax script').forEach(element => {
    var code = element.text || element.textContent || element.innerHTML || '';
    var parent = element.parentNode;
    parent.removeChild(element);
    var script = document.createElement('script');
    if (element.id) {
      script.id = element.id;
    }
    if (element.className) {
      script.className = element.className;
    }
    if (element.type) {
      script.type = element.type;
    }
    if (element.src) {
      script.src = element.src;
      // Force synchronous loading of peripheral JS.
      script.async = false;
    }
    if (element.dataset.pjax !== undefined) {
      script.dataset.pjax = '';
    }
    if (code !== '') {
      script.appendChild(document.createTextNode(code));
    }
    parent.appendChild(script);
  });
  NexT.boot.refresh();
  // Define Motion Sequence & Bootstrap Motion.
  if (CONFIG.motion.enable) {
    NexT.motion.integrator
      .init()
      .add(NexT.motion.middleWares.subMenu)
      .add(NexT.motion.middleWares.postList)
      .bootstrap();
  }
  NexT.utils.updateSidebarPosition();
});
</script>


  <script defer src="/lib/three/three.min.js"></script>
    <script defer src="/lib/three/three-waves.min.js"></script>


  




  
<script src="/js/local-search.js"></script>













    <div id="pjax">
  

  


    </div>

        <style>
            [bg-lazy] {
                background-image: none !important;
                background-color: #eee !important;
            }
        </style>
        <script>
            window.imageLazyLoadSetting = {
                isSPA: true,
                preloadRatio: 1,
                processImages: null,
            };
        </script><script>window.addEventListener("load",function(){var t=/\.(gif|jpg|jpeg|tiff|png)$/i,r=/^data:image\/[a-z]+;base64,/;Array.prototype.slice.call(document.querySelectorAll("img[data-original]")).forEach(function(a){var e=a.parentNode;"A"===e.tagName&&(e.href.match(t)||e.href.match(r))&&(e.href=a.dataset.original)})});</script><script>!function(r){r.imageLazyLoadSetting.processImages=t;var e=r.imageLazyLoadSetting.isSPA,n=r.imageLazyLoadSetting.preloadRatio||1,c=a();function a(){var t=Array.prototype.slice.call(document.querySelectorAll("img[data-original]")),e=Array.prototype.slice.call(document.querySelectorAll("[bg-lazy]"));return t.concat(e)}function t(){e&&(c=a());for(var t,o=0;o<c.length;o++)0<=(t=(t=c[o]).getBoundingClientRect()).bottom&&0<=t.left&&t.top<=(r.innerHeight*n||document.documentElement.clientHeight*n)&&function(){var t,e,n,a,i=c[o];e=function(){c=c.filter(function(t){return i!==t}),r.imageLazyLoadSetting.onImageLoaded&&r.imageLazyLoadSetting.onImageLoaded(i)},(t=i).hasAttribute("bg-lazy")?(t.removeAttribute("bg-lazy"),e&&e()):(n=new Image,a=t.getAttribute("data-original"),n.onload=function(){t.src=a,t.removeAttribute("data-original"),e&&e()},t.src!==a&&(n.src=a))}()}function i(){clearTimeout(t.tId),t.tId=setTimeout(t,500)}t(),document.addEventListener("scroll",i),r.addEventListener("resize",i),r.addEventListener("orientationchange",i)}(this);</script><script async>window.onload=function(){var a=document.createElement('script'),b=document.getElementsByTagName('script')[0];a.type='text/javascript',a.async=!0,a.src='/sw-register.js?v='+Date.now(),b.parentNode.insertBefore(a,b)};</script></body></html>